import ajax from './ajax'
import myAjax from './myAjax'

// 获取首页数据
export const reqIndexData = () => ajax.get('/xhr/index.json?__timestamp=1630131808529')

// ‘为你推荐’和分类列表的数据
export const reqCateList = (categoryId = '') => ajax.get(`/item/cateList.json?__timestamp=${new Date().getTime()} &categoryId=${categoryId}`)


// 根据分类id 获取 商品列表数据
export const reqProductList = (categoryId = '') => ajax.get(`/item/list.json?__timestamp=${new Date().getTime()}&categoryId=${categoryId}`)

// 获取某个分类下的商品列表
export const reqGoodsList = (categoryId = '', subCategoryId = '') =>
  ajax.get(`/item/list.json?__timestamp=${new Date().getTime()}&categoryId=${categoryId}&subCategoryId=${subCategoryId}&categoryType=0`)

// 获取商品详情页数据
export const reqSkuDetail = (skuId) => ajax.get(`/item/detail.json?__timestamp=${new Date().getTime()}&id=${skuId}`)

// 获取热门搜索关键字
export const reqHotSearchKeyWordList =  ()=> ajax.get('/xhr/search/init.json')

// 自动补全关键字提示
export const reqSearchAotoComplete = (keywordPrefix)=> ajax.post('/xhr/search/searchAutoComplete.json','keywordPrefix='+keywordPrefix,{
  headers: {
    'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
  }
})

// 搜索商品信息
export const reqSearchProductList = (searchInfo)=> ajax.get('/xhr/search/search.json',{
  params: searchInfo
})

//注册账号
export const reqRegister = (registerInfo) => myAjax.post('/users/register', registerInfo)

//登录账号
export const loginRegister = (registerInfo) => myAjax.post('/users/login', registerInfo)

//获取个人信息

export const getinfo = () => myAjax.get(`/users/getUserInfo`)

//获取购物车信息
export const getShopCartList = () => myAjax.get(`/cart/getCartList`)

//获取值得买瀑布路流数据
export const reqWaterfallFlow = (pageNum) =>ajax.get('/topic/v1/find/recAuto.json?page='+pageNum +'&size=2')

//修改购物车选中状态的
export const changeCartOnecheck = (data) => myAjax.post(`/cart/changeCheck`,data)

//修改购物车的数量
export const changeCartCount = (data) => myAjax.post(`/cart/changeCount`,data)

// 给购物车添加商品
export const addCart = (productInfo) => myAjax.post(`/cart/saveCart`,productInfo)


//获取值得买轮播图数据
export const reqShufflinfigure = () => ajax.get('/topic/v1/know/navWap.json')

